/**
 * 
 */
package com.nari.interfaces.utils;

import java.util.ArrayList;
import java.util.List;

import com.nari.heatshare.model.IAssignMeterDataGather;
import com.nari.interfaces.model.IAssignMeterDataBuffer;
import com.nari.interfaces.model.IHeatMeterData24Gather;
import com.nari.interfaces.model.IHeatMeterDataBuffer;
import com.nari.interfaces.utils.entityconvert.AssignMeterData2Buffer;
import com.nari.interfaces.utils.entityconvert.Buffer2AssignMeterData;
import com.nari.interfaces.utils.entityconvert.Buffer2HeatMeterData;
import com.nari.interfaces.utils.entityconvert.HeatMeterData2Buffer;

/**
 * 
 * @author Xiaopeng
 * @date 2013-11-12
 */
public class MeterData2BufferUtil {
	
	/**
	 * 缓存数据转化为分配表数据列表
	 * @param bufferData
	 * @param entityConvert
	 * @return
	 * @author Xiaopeng
	 * @date 2013-11-12
	 */
	public static List<IAssignMeterDataGather> buffer2AssignMeterData(List<IAssignMeterDataBuffer> bufferDatas, 
			Buffer2AssignMeterData entityConvert) throws Exception {
		if(bufferDatas!=null && bufferDatas.size()>0) {
			List<IAssignMeterDataGather> meterDatas = new ArrayList<IAssignMeterDataGather>();
			for(IAssignMeterDataBuffer bufferData: bufferDatas) {
				meterDatas.add(entityConvert.convert(bufferData));
			}
			return meterDatas;
		}
		return null;
	}
	
	/**
	 * 分配表数据列表转化为缓存数据
	 * @param meterDatas
	 * @param entityConvert
	 * @return
	 * @author Xiaopeng
	 * @date 2013-11-12
	 */
	public static List<IAssignMeterDataBuffer> assignMeterData2buffer(List<IAssignMeterDataGather> meterDatas, 
			AssignMeterData2Buffer entityConvert) throws Exception {
		if(meterDatas!=null && meterDatas.size()>0) {
			List<IAssignMeterDataBuffer> bufferDatas = new ArrayList<IAssignMeterDataBuffer>();
			for(IAssignMeterDataGather meterData: meterDatas) {
				bufferDatas.add(entityConvert.convert(meterData));
			}
			return bufferDatas;
		}
		return null;
	}
	
	/**
	 * 缓存数据转化为热量表数据列表
	 * @param bufferDatas
	 * @param entityConvert
	 * @return
	 * @author Xiaopeng
	 * @date 2013-11-12
	 */
	public static List<IHeatMeterData24Gather> buffer2HeatMeterData(List<IHeatMeterDataBuffer> bufferDatas, 
			Buffer2HeatMeterData entityConvert) throws Exception {
		if(bufferDatas!=null && bufferDatas.size()>0) {
			List<IHeatMeterData24Gather> meterDatas = new ArrayList<IHeatMeterData24Gather>();
			for(IHeatMeterDataBuffer bufferData: bufferDatas) {
				meterDatas.add(entityConvert.convert(bufferData));
			}
			return meterDatas;
		}
		return null;
	}
	
	/**
	 * 热量表数据列表转化为缓存数据
	 * @param meterDatas
	 * @param entityConvert
	 * @return
	 * @author Xiaopeng
	 * @date 2013-11-12
	 */
	public static List<IHeatMeterDataBuffer> heatMeterData2Buffer(List<IHeatMeterData24Gather> meterDatas, 
			HeatMeterData2Buffer entityConvert) throws Exception {
		if(meterDatas!=null && meterDatas.size()>0) {
			List<IHeatMeterDataBuffer> bufferDatas = new ArrayList<IHeatMeterDataBuffer>();
			for(IHeatMeterData24Gather meterData: meterDatas) {
				bufferDatas.add(entityConvert.convert(meterData));
			}
			return bufferDatas;
		}
		return null;
	}
}
